package io.ent.modules.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.ent.common.utils.PageUtils;
import io.ent.common.utils.Query;
import io.ent.modules.product.dao.ProductTypeDao;
import io.ent.modules.product.entity.ProductTypeEntity;
import io.ent.modules.product.po.ProductTypeEntityIfPo;
import io.ent.modules.product.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("productTypeService")
public class ProductTypeServiceImpl extends ServiceImpl<ProductTypeDao, ProductTypeEntity> implements ProductTypeService {
    @Autowired
    private ProductTypeDao productTypeDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ProductTypeEntity> page = this.page(
                new Query<ProductTypeEntity>().getPage(params),
                new QueryWrapper<ProductTypeEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 获取类型
     * @return
     */
    public List<ProductTypeEntity> getAllProductTypes() {
        QueryWrapper<ProductTypeEntity> wrapper = new QueryWrapper<>();
        return list(wrapper);
    }

    @Override
    public List<ProductTypeEntityIfPo> getProductTypes() {
        List<ProductTypeEntityIfPo> productTypes = productTypeDao.getProductTypes();
        return productTypes;
    }

}
